package com.emm.yixun.mobile.ui.personal;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSONObject;
import com.emm.yixun.mobile.R;
import com.emm.yixun.mobile.adapter.MainProjectAdapter;
import com.emm.yixun.mobile.application.EmmApplication;
import com.emm.yixun.mobile.base.BaseActivity;
import com.emm.yixun.mobile.model.GetHeroList;
import com.emm.yixun.mobile.model.GetProjectList;
import com.emm.yixun.mobile.model.GetProjectList.ProjectList;
import com.eroad.product.tools.PickerView;
import com.eroad.product.tools.PickerView.onSelectListener;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import xf.tools.Loading;
import xf.tools.RoundImageView;

/** 英雄榜 */
public class PersonalFragment extends Fragment {

	private static final String TAG = "PersonalFragment";

	FragmentActivity root = null;

	/* ---公用选择框--- */
	View view;
	PopupWindow popu;
	/** 选中内容 */
	String selectName;
	/** 选中下标 */
	int SelectID;
	ArrayList<String> listname;
	/* ---公用选择框--- */

	/** 英雄榜数据 */
	GetHeroList gethero;

	/** 头像 */
	RoundImageView rd_touxiang1, rd_touxiang2, rd_touxiang3, rd_touxiang4, rd_touxiang5, rd_touxiang6, rd_touxiang7,
			rd_touxiang8, rd_touxiang9;

	/** 名称 */
	TextView name_count1, name_count2, name_count3, name_count4, name_count5, name_count6, name_count7, name_count8,
			name_count9;

	LinearLayout screen_textview;

	LinearLayout sort_textview;

	TextView colors_text2;

	ImageView icon2;

	TextView colors_text;

	ImageView icon1;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		return inflater.inflate(R.layout.personal_frg, null);
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		root = getActivity();

		initView();
		getHeroList(1, "1", 1, 1);
	}

	/**
	 * 
	 * <p>
	 * <b>Title：</b> 初始化view
	 * </p>
	 * <p>
	 * <b>Description：</b>
	 * </p>
	 * 
	 * @author tangxin
	 * @date 2016年12月7日 下午4:24:28
	 */
	private void initView() {
		rd_touxiang1 = (RoundImageView) root.findViewById(R.id.rd_touxiang1);
		rd_touxiang2 = (RoundImageView) root.findViewById(R.id.rd_touxiang2);
		rd_touxiang3 = (RoundImageView) root.findViewById(R.id.rd_touxiang3);
		rd_touxiang4 = (RoundImageView) root.findViewById(R.id.rd_touxiang4);
		rd_touxiang5 = (RoundImageView) root.findViewById(R.id.rd_touxiang5);
		rd_touxiang6 = (RoundImageView) root.findViewById(R.id.rd_touxiang6);
		rd_touxiang7 = (RoundImageView) root.findViewById(R.id.rd_touxiang7);
		rd_touxiang8 = (RoundImageView) root.findViewById(R.id.rd_touxiang8);
		rd_touxiang9 = (RoundImageView) root.findViewById(R.id.rd_touxiang9);
		name_count1 = (TextView) root.findViewById(R.id.name_count1);
		name_count2 = (TextView) root.findViewById(R.id.name_count2);
		name_count3 = (TextView) root.findViewById(R.id.name_count3);
		name_count4 = (TextView) root.findViewById(R.id.name_count4);
		name_count5 = (TextView) root.findViewById(R.id.name_count5);
		name_count6 = (TextView) root.findViewById(R.id.name_count6);
		name_count7 = (TextView) root.findViewById(R.id.name_count7);
		name_count8 = (TextView) root.findViewById(R.id.name_count8);
		name_count9 = (TextView) root.findViewById(R.id.name_count9);

		screen_textview = (LinearLayout) root.findViewById(R.id.screen_textview);
		colors_text2 = (TextView) root.findViewById(R.id.colors_text2);
		icon2 = (ImageView) root.findViewById(R.id.icon2);
		sort_textview = (LinearLayout) root.findViewById(R.id.sort_textview);
		colors_text = (TextView) root.findViewById(R.id.colors_text);
		icon1 = (ImageView) root.findViewById(R.id.icon1);

		sort_textview.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				colors_text.setTextColor(Color.parseColor("#FD593E"));
				colors_text2.setTextColor(Color.parseColor("#3E3C3D"));
				icon1.setImageResource(R.drawable.paixu_down);
				icon2.setImageResource(R.drawable.shaixuan_up);
				SetsortPopu(0);
			}
		});
		screen_textview.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				colors_text.setTextColor(Color.parseColor("#3E3C3D"));
				colors_text2.setTextColor(Color.parseColor("#FD593E"));
				icon1.setImageResource(R.drawable.paixu_up);
				icon2.setImageResource(R.drawable.shaixuan_down);
				SetsortPopu(1);
			}
		});

	}

	View viewproject;
	PopupWindow popuproject;
	/** 时间 */
	private int SelectPostion = 0;

	/** 类别 */
	private int SelectPostion2 = 0;

	/**
	 * 
	 * <p>
	 * <b>Title：</b> 选择条件弹出框
	 * </p>
	 * <p>
	 * <b>Description：</b>
	 * </p>
	 * 
	 * @param type
	 * @author tangxin
	 * @date 2016年12月7日 下午4:26:09
	 */
	public void SetsortPopu(int type) {
		viewproject = LayoutInflater.from(root).inflate(R.layout.mainproject_popu, null);
		popuproject = new PopupWindow(viewproject, android.support.v4.view.ViewPager.LayoutParams.FILL_PARENT,
				android.support.v4.view.ViewPager.LayoutParams.FILL_PARENT);
		popuproject.setFocusable(true);
		popuproject.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
		popuproject.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
		popuproject.showAtLocation(sort_textview, Gravity.TOP, 0, 0);
		popuproject.setFocusable(true);
		popuproject.setOutsideTouchable(true);
		viewproject.setFocusable(true);
		viewproject.setFocusableInTouchMode(true);
		viewproject.setOnKeyListener(new OnKeyListener() {
			@Override
			public boolean onKey(View v, int keyCode, KeyEvent event) {
				if (keyCode == KeyEvent.KEYCODE_BACK) {
					popuproject.dismiss();
					EmmApplication.setLog(root);
				}
				return false;
			}
		});

		viewproject.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				popuproject.dismiss();
				EmmApplication.setLog(root);
			}
		});

		ListView popu_list = (ListView) viewproject.findViewById(R.id.popu_list);
		RelativeLayout top_relativelayout = (RelativeLayout) viewproject.findViewById(R.id.top_relativelayout);
		BaseActivity.SetViewPaddingHeight(top_relativelayout, 95);
		ArrayList<ProjectList> ll = new ArrayList<ProjectList>();
		if (type == 1) {

			ProjectList m = new ProjectList();
			m.setProjectCode("1");
			m.setProjectName("今日");
			ll.add(m);

			ProjectList m2 = new ProjectList();
			m2.setProjectCode("2");
			m2.setProjectName("昨日");
			ll.add(m2);

			ProjectList m3 = new ProjectList();
			m3.setProjectCode("3");
			m3.setProjectName("本周");
			ll.add(m3);

			ProjectList m4 = new ProjectList();
			m4.setProjectCode("4");
			m4.setProjectName("上周");
			ll.add(m4);

			ProjectList m5 = new ProjectList();
			m5.setProjectCode("5");
			m5.setProjectName("本月");
			ll.add(m5);

			ProjectList m6 = new ProjectList();
			m6.setProjectCode("6");
			m6.setProjectName("上月");
			ll.add(m6);

			ProjectList m7 = new ProjectList();
			m7.setProjectCode("7");
			m7.setProjectName("三月内");
			ll.add(m7);

			ProjectList m8 = new ProjectList();
			m8.setProjectCode("8");
			m8.setProjectName("全部");
			ll.add(m8);

			final GetProjectList list = new GetProjectList();
			list.setProjectList(ll);

			MainProjectAdapter adapter = new MainProjectAdapter(root, list);
			popu_list.setAdapter(adapter);
			adapter.SetType(1);
			if (list.getProjectList().size() >= (SelectPostion + 1)) {
				adapter.SeleCt(SelectPostion);
				colors_text2.setText(list.getProjectList().get(SelectPostion).getProjectName());
			} else {
				adapter.SeleCt(0);
				colors_text2.setText(list.getProjectList().get(0).getProjectName());
			}
			popu_list.setOnItemClickListener(new OnItemClickListener() {
				@Override
				public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
					popuproject.dismiss();
					SelectPostion = position;
					EmmApplication.setLog(root);
					colors_text2.setText(list.getProjectList().get(position).getProjectName());
					int numbertype = SelectPostion + 1;
					Log.v(TAG, "numbertype:==>" + numbertype);

					getHeroList(1, "" + numbertype, 1, (SelectPostion2 + 1));
				}
			});

		} else {
			ProjectList m = new ProjectList();
			m.setProjectCode("1");
			m.setProjectName("按数量");
			ll.add(m);

			ProjectList m2 = new ProjectList();
			m2.setProjectCode("2");
			m2.setProjectName("按金额");
			ll.add(m2);

			final GetProjectList list = new GetProjectList();
			list.setProjectList(ll);

			MainProjectAdapter adapter = new MainProjectAdapter(root, list);
			popu_list.setAdapter(adapter);
			adapter.SetType(1);

			if (list.getProjectList().size() >= (SelectPostion2 + 1)) {
				adapter.SeleCt(SelectPostion2);
				colors_text.setText(list.getProjectList().get(SelectPostion2).getProjectName());
			} else {
				adapter.SeleCt(0);
				colors_text.setText(list.getProjectList().get(0).getProjectName());
			}
			popu_list.setOnItemClickListener(new OnItemClickListener() {
				@Override
				public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
					popuproject.dismiss();
					SelectPostion2 = position;
					EmmApplication.setLog(root);
					colors_text.setText(list.getProjectList().get(position).getProjectName());
					int numbertype2 = SelectPostion2 + 1;
					Log.v(TAG, "numbertype2:==>" + numbertype2);

					getHeroList(1, "" + (SelectPostion + 1), 1, numbertype2);
				}
			});

		}
	}

	/**
	 * 
	 * <p>
	 * <b>Title：</b> 选项框
	 * </p>
	 * <p>
	 * <b>Description：</b>
	 * </p>
	 * 
	 * @param listname
	 * @param title
	 * @param ed
	 * @param type
	 * @author tangxin
	 * @date 2016年12月7日 下午4:26:44
	 */
	public void SetzpPopu(final List<String> listname, String title, final TextView ed, final int type) {
		view = LayoutInflater.from(root).inflate(R.layout.popu_zp, null);
		popu = new PopupWindow(view, android.support.v4.view.ViewPager.LayoutParams.FILL_PARENT,
				android.support.v4.view.ViewPager.LayoutParams.FILL_PARENT);
		popu.setFocusable(true);
		// EmmApplication.setNumberLog(root, 0.5f);// 改变popupwindow范围外的屏幕亮度
		popu.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
		popu.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
		popu.showAtLocation(view, Gravity.BOTTOM, 0, 0);
		popu.showAsDropDown(view, 0, 0);
		popu.setFocusable(true);
		popu.setOutsideTouchable(true);
		view.setFocusable(true);
		view.setFocusableInTouchMode(true);
		view.setOnKeyListener(new OnKeyListener() {
			@Override
			public boolean onKey(View v, int keyCode, KeyEvent event) {
				if (keyCode == KeyEvent.KEYCODE_BACK) {
					popu.dismiss();
					EmmApplication.setLog(root);
				}
				return false;
			}
		});
		view.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				popu.dismiss();
				EmmApplication.setLog(root);
			}
		});

		PickerView select_pick = (PickerView) view.findViewById(R.id.select_pick);

		selectName = listname.get(0);

		TextView shuerbtn = (TextView) view.findViewById(R.id.shuerbtn);
		RelativeLayout relative_all = (RelativeLayout) view.findViewById(R.id.relative_all);

		ImageView dis_btn = (ImageView) view.findViewById(R.id.dis_btn);
		dis_btn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				popu.dismiss();
				EmmApplication.setLog(root);
			}
		});
		TextView title_select = (TextView) view.findViewById(R.id.title_select);

		title_select.setText(title);

		select_pick.setData(listname);
		select_pick.setOnSelectListener(new onSelectListener() {
			@Override
			public void onSelect(String text, int id) {
				selectName = text;
				SelectID = id;
				Log.v("SelectID--><", "" + id + "-/text:" + text);
			}
		});
		select_pick.setSelected(0);
		shuerbtn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// 确定
				popu.dismiss();
				EmmApplication.setLog(root);
				ed.setText(selectName);
				// 1认筹 2 认购 3 签约
				int typed = 0;
				// 1、今日 【默认】；2、昨日；3、本周；4、上周；5、本月；6、上月；7、三月内；8、全部
				if ("今日".equals(selectName.subSequence(0, 2))) {
					typed = 1;
				} else if ("昨日".equals(selectName.subSequence(0, 2))) {
					typed = 2;
				} else if ("本周".equals(selectName.subSequence(0, 2))) {
					typed = 3;
				} else if ("上周".equals(selectName.subSequence(0, 2))) {
					typed = 4;
				} else if ("本月".equals(selectName.subSequence(0, 2))) {
					typed = 5;
				} else if ("上月".equals(selectName.subSequence(0, 2))) {
					typed = 6;
				} else if ("三月内".equals(selectName.subSequence(0, 3))) {
					typed = 7;
				} else if ("全部".equals(selectName.subSequence(0, 2))) {
					typed = 8;
				}
			}
		});
		relative_all.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
			}
		});
	}

	/**
	 * 
	 * <p>
	 * <b>Title：</b> type:1认筹 2 认购 3 签约 open:1默认 2接下一个 0不管 cusSort:1按数量 2按金额
	 * </p>
	 * <p>
	 * <b>Description：</b>
	 * </p>
	 * 
	 * @param type
	 * @param timeType
	 * @param open
	 * @param cusSort
	 * @author tangxin
	 * @date 2016年12月7日 下午4:27:01
	 */
	private void getHeroList(final int type, final String timeType, final int open, final int cusSort) {
		EmmApplication.updateUrl("getHeroList");
		Log.v(TAG, "type:" + type + "/timeType:" + timeType + "/open:" + open + "/cusSort:" + cusSort);
		Map<String, String> map = new HashMap<String, String>();
		map.put("version", EmmApplication.getPackageManager(5));
		map.put("merchantId", EmmApplication.getData(EmmApplication.merchantId));
		map.put("token", EmmApplication.getToken());
		map.put("userId", EmmApplication.getUserId());
		map.put("terminalCode", EmmApplication.getPackageManager(2));
		map.put("projectCode", EmmApplication.getProjectCode());
		Log.v(TAG, "timeType" + timeType);
		map.put("timeType", timeType);
		map.put("cusType", "" + type);
		map.put("cusSort", "" + cusSort);
		Map<String, Object> paramsMap = new HashMap<String, Object>();
		paramsMap.put("params", map);
		JSONObject json = new JSONObject(paramsMap);
		String jsonstr = json.toString();
		RequestParams params = new RequestParams();
		params.put("body", jsonstr);
		Log.v("getHeroList-->post", EmmApplication.urlStr + "?body=" + jsonstr);
		AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
		asyncHttpClient.post(EmmApplication.urlStr, params, new AsyncHttpResponseHandler() {
			@Override
			public void onFailure(Throwable error, String content) {
				super.onFailure(error, content);
				Loading.hideDialogForLoading();
				Log.v(TAG, "请求结束error:" + error + "==" + content);
			}

			@Override
			public void onFinish() {
				if (open == 0) {
					Loading.hideDialogForLoading();
				}
				Log.v(TAG, "请求结束");
				super.onFinish();
			}

			@Override
			public void onStart() {
				super.onStart();
				Loading.hideDialogForLoading();
				if (open == 1) {
					Loading.showDialogForLoading(root, "正在加载...", false, true, 60000);
				}
				Log.v(TAG, "请求开始");
			}

			@Override
			public void onSuccess(String content) {
				super.onSuccess(content);
				if (content == null) {
					return;
				}
				Log.v(TAG, "content->" + content);
				JSONObject jsonObj = JSONObject.parseObject(content);
				JSONObject resData = (JSONObject) jsonObj.get("resData");
				if (resData == null) {
					Log.v(TAG, "信息返回值为空");
					return;
				}
				gethero = JSONObject.parseObject(resData.toString(), GetHeroList.class);
				if ("1".equals(gethero.getResult())) {
					Log.v("获取成功", "");
					EmmApplication.image(R.drawable.touxiang);
					if (cusSort == 1) {// 1、按数量；2、按金额
						if (type == 1) {// 认筹
							if (gethero.getHeroList() != null && gethero.getHeroList().size() == 1) {
								playimage(gethero.getHeroList().get(0).getHeadPic(), rd_touxiang1);
								name_count1.setText(gethero.getHeroList().get(0).getAgent() + "("
										+ gethero.getHeroList().get(0).getCusNum() + ")");
								name_count2.setText("???");
								name_count3.setText("???");
								playimage("111", rd_touxiang2);
								playimage("111", rd_touxiang3);
							} else if (gethero.getHeroList() != null && gethero.getHeroList().size() == 2) {
								playimage(gethero.getHeroList().get(0).getHeadPic(), rd_touxiang1);
								name_count1.setText(gethero.getHeroList().get(0).getAgent() + "("
										+ gethero.getHeroList().get(0).getCusNum() + ")");
								playimage(gethero.getHeroList().get(1).getHeadPic(), rd_touxiang2);
								name_count2.setText(gethero.getHeroList().get(1).getAgent() + "("
										+ gethero.getHeroList().get(1).getCusNum() + ")");
								name_count3.setText("???");
								playimage("111", rd_touxiang3);
							} else if (gethero.getHeroList() != null && gethero.getHeroList().size() > 2) {
								playimage(gethero.getHeroList().get(0).getHeadPic(), rd_touxiang1);
								name_count1.setText(gethero.getHeroList().get(0).getAgent() + "("
										+ gethero.getHeroList().get(0).getCusNum() + ")");
								playimage(gethero.getHeroList().get(1).getHeadPic(), rd_touxiang2);
								name_count2.setText(gethero.getHeroList().get(1).getAgent() + "("
										+ gethero.getHeroList().get(1).getCusNum() + ")");
								playimage(gethero.getHeroList().get(2).getHeadPic(), rd_touxiang3);
								name_count3.setText(gethero.getHeroList().get(2).getAgent() + "("
										+ gethero.getHeroList().get(2).getCusNum() + ")");
							}
							if (null == gethero.getHeroList()) {
								name_count1.setText("???");
								name_count2.setText("???");
								name_count3.setText("???");
								playimage("111", rd_touxiang1);
								playimage("111", rd_touxiang2);
								playimage("111", rd_touxiang3);
							}
						} else if (type == 2) {// 认购
							if (gethero.getHeroList() != null && gethero.getHeroList().size() == 1) {
								playimage(gethero.getHeroList().get(0).getHeadPic(), rd_touxiang4);
								name_count4.setText(gethero.getHeroList().get(0).getAgent() + "("
										+ gethero.getHeroList().get(0).getCusNum() + ")");
								name_count5.setText("???");
								name_count6.setText("???");
								playimage("111", rd_touxiang5);
								playimage("111", rd_touxiang6);
							} else if (gethero.getHeroList() != null && gethero.getHeroList().size() == 2) {
								playimage(gethero.getHeroList().get(0).getHeadPic(), rd_touxiang4);
								name_count4.setText(gethero.getHeroList().get(0).getAgent() + "("
										+ gethero.getHeroList().get(0).getCusNum() + ")");
								playimage(gethero.getHeroList().get(1).getHeadPic(), rd_touxiang5);
								name_count5.setText(gethero.getHeroList().get(1).getAgent() + "("
										+ gethero.getHeroList().get(1).getCusNum() + ")");
								name_count6.setText("???");
								playimage("111", rd_touxiang6);
							} else if (gethero.getHeroList() != null && gethero.getHeroList().size() > 2) {
								playimage(gethero.getHeroList().get(0).getHeadPic(), rd_touxiang4);
								name_count4.setText(gethero.getHeroList().get(0).getAgent() + "("
										+ gethero.getHeroList().get(0).getCusNum() + ")");
								playimage(gethero.getHeroList().get(1).getHeadPic(), rd_touxiang5);
								name_count5.setText(gethero.getHeroList().get(1).getAgent() + "("
										+ gethero.getHeroList().get(1).getCusNum() + ")");
								playimage(gethero.getHeroList().get(2).getHeadPic(), rd_touxiang6);
								name_count6.setText(gethero.getHeroList().get(2).getAgent() + "("
										+ gethero.getHeroList().get(2).getCusNum() + ")");
							}
							if (null == gethero.getHeroList()) {
								name_count4.setText("???");
								name_count5.setText("???");
								name_count6.setText("???");
								playimage("111", rd_touxiang4);
								playimage("111", rd_touxiang5);
								playimage("111", rd_touxiang6);
							}
						} else if (type == 3) {// 签约
							if (gethero.getHeroList() != null && gethero.getHeroList().size() == 1) {
								playimage(gethero.getHeroList().get(0).getHeadPic(), rd_touxiang7);
								name_count7.setText(gethero.getHeroList().get(0).getAgent() + "("
										+ gethero.getHeroList().get(0).getCusNum() + ")");
								name_count8.setText("???");
								name_count9.setText("???");
								playimage("111", rd_touxiang8);
								playimage("111", rd_touxiang9);
							} else if (gethero.getHeroList() != null && gethero.getHeroList().size() == 2) {
								playimage(gethero.getHeroList().get(0).getHeadPic(), rd_touxiang7);
								name_count7.setText(gethero.getHeroList().get(0).getAgent() + "("
										+ gethero.getHeroList().get(0).getCusNum() + ")");
								playimage(gethero.getHeroList().get(1).getHeadPic(), rd_touxiang8);
								name_count8.setText(gethero.getHeroList().get(1).getAgent() + "("
										+ gethero.getHeroList().get(1).getCusNum() + ")");
								name_count9.setText("???");
								playimage("111", rd_touxiang9);
							} else if (gethero.getHeroList() != null && gethero.getHeroList().size() > 2) {
								playimage(gethero.getHeroList().get(0).getHeadPic(), rd_touxiang7);
								name_count7.setText(gethero.getHeroList().get(0).getAgent() + "("
										+ gethero.getHeroList().get(0).getCusNum() + ")");
								playimage(gethero.getHeroList().get(1).getHeadPic(), rd_touxiang8);
								name_count8.setText(gethero.getHeroList().get(1).getAgent() + "("
										+ gethero.getHeroList().get(1).getCusNum() + ")");
								playimage(gethero.getHeroList().get(2).getHeadPic(), rd_touxiang9);
								name_count9.setText(gethero.getHeroList().get(2).getAgent() + "("
										+ gethero.getHeroList().get(2).getCusNum() + ")");
							}
							if (null == gethero.getHeroList()) {
								name_count7.setText("???");
								name_count8.setText("???");
								name_count9.setText("???");
								playimage("111", rd_touxiang7);
								playimage("111", rd_touxiang8);
								playimage("111", rd_touxiang9);
							}
						}
					} else {// 2、按金额
						if (type == 1) {// 认筹
							if (gethero.getHeroList() != null && gethero.getHeroList().size() == 1) {
								playimage(gethero.getHeroList().get(0).getHeadPic(), rd_touxiang1);
								name_count1.setText(gethero.getHeroList().get(0).getAgent() + "("
										+ gethero.getHeroList().get(0).getCusAmount() + "万元)");
								name_count2.setText("???");
								name_count3.setText("???");
								playimage("111", rd_touxiang2);
								playimage("111", rd_touxiang3);
							} else if (gethero.getHeroList() != null && gethero.getHeroList().size() == 2) {
								playimage(gethero.getHeroList().get(0).getHeadPic(), rd_touxiang1);
								name_count1.setText(gethero.getHeroList().get(0).getAgent() + "("
										+ gethero.getHeroList().get(0).getCusAmount() + "万元)");
								playimage(gethero.getHeroList().get(1).getHeadPic(), rd_touxiang2);
								name_count2.setText(gethero.getHeroList().get(1).getAgent() + "("
										+ gethero.getHeroList().get(1).getCusAmount() + "万元)");
								name_count3.setText("???");
								playimage("111", rd_touxiang3);
							} else if (gethero.getHeroList() != null && gethero.getHeroList().size() > 2) {
								playimage(gethero.getHeroList().get(0).getHeadPic(), rd_touxiang1);
								name_count1.setText(gethero.getHeroList().get(0).getAgent() + "("
										+ gethero.getHeroList().get(0).getCusAmount() + "万元)");
								playimage(gethero.getHeroList().get(1).getHeadPic(), rd_touxiang2);
								name_count2.setText(gethero.getHeroList().get(1).getAgent() + "("
										+ gethero.getHeroList().get(1).getCusAmount() + "万元)");
								playimage(gethero.getHeroList().get(2).getHeadPic(), rd_touxiang3);
								name_count3.setText(gethero.getHeroList().get(2).getAgent() + "("
										+ gethero.getHeroList().get(2).getCusAmount() + "万元)");
							}
							if (null == gethero.getHeroList()) {
								name_count1.setText("???");
								name_count2.setText("???");
								name_count3.setText("???");
								playimage("111", rd_touxiang1);
								playimage("111", rd_touxiang2);
								playimage("111", rd_touxiang3);
							}
						} else if (type == 2) {// 认购
							if (gethero.getHeroList() != null && gethero.getHeroList().size() == 1) {
								playimage(gethero.getHeroList().get(0).getHeadPic(), rd_touxiang4);
								name_count4.setText(gethero.getHeroList().get(0).getAgent() + "("
										+ gethero.getHeroList().get(0).getCusAmount() + "万元)");
								name_count5.setText("???");
								name_count6.setText("???");
								playimage("111", rd_touxiang5);
								playimage("111", rd_touxiang6);
							} else if (gethero.getHeroList() != null && gethero.getHeroList().size() == 2) {
								playimage(gethero.getHeroList().get(0).getHeadPic(), rd_touxiang4);
								name_count4.setText(gethero.getHeroList().get(0).getAgent() + "("
										+ gethero.getHeroList().get(0).getCusAmount() + "万元)");
								playimage(gethero.getHeroList().get(1).getHeadPic(), rd_touxiang5);
								name_count5.setText(gethero.getHeroList().get(1).getAgent() + "("
										+ gethero.getHeroList().get(1).getCusAmount() + "万元)");
								name_count6.setText("???");
								playimage("111", rd_touxiang6);
							} else if (gethero.getHeroList() != null && gethero.getHeroList().size() > 2) {
								playimage(gethero.getHeroList().get(0).getHeadPic(), rd_touxiang4);
								name_count4.setText(gethero.getHeroList().get(0).getAgent() + "("
										+ gethero.getHeroList().get(0).getCusAmount() + "万元)");
								playimage(gethero.getHeroList().get(1).getHeadPic(), rd_touxiang5);
								name_count5.setText(gethero.getHeroList().get(1).getAgent() + "("
										+ gethero.getHeroList().get(1).getCusAmount() + "万元)");
								playimage(gethero.getHeroList().get(2).getHeadPic(), rd_touxiang6);
								name_count6.setText(gethero.getHeroList().get(2).getAgent() + "("
										+ gethero.getHeroList().get(2).getCusAmount() + "万元)");
							}
							if (null == gethero.getHeroList()) {
								name_count4.setText("???");
								name_count5.setText("???");
								name_count6.setText("???");
								playimage("111", rd_touxiang4);
								playimage("111", rd_touxiang5);
								playimage("111", rd_touxiang6);
							}
						} else if (type == 3) {// 签约
							if (gethero.getHeroList() != null && gethero.getHeroList().size() == 1) {
								playimage(gethero.getHeroList().get(0).getHeadPic(), rd_touxiang7);
								name_count7.setText(gethero.getHeroList().get(0).getAgent() + "("
										+ gethero.getHeroList().get(0).getCusAmount() + "万元)");
								name_count8.setText("???");
								name_count9.setText("???");
								playimage("111", rd_touxiang8);
								playimage("111", rd_touxiang9);
							} else if (gethero.getHeroList() != null && gethero.getHeroList().size() == 2) {
								playimage(gethero.getHeroList().get(0).getHeadPic(), rd_touxiang7);
								name_count7.setText(gethero.getHeroList().get(0).getAgent() + "("
										+ gethero.getHeroList().get(0).getCusAmount() + "万元)");
								playimage(gethero.getHeroList().get(1).getHeadPic(), rd_touxiang8);
								name_count8.setText(gethero.getHeroList().get(1).getAgent() + "("
										+ gethero.getHeroList().get(1).getCusAmount() + "万元)");
								name_count9.setText("???");
								playimage("111", rd_touxiang9);
							} else if (gethero.getHeroList() != null && gethero.getHeroList().size() > 2) {
								playimage(gethero.getHeroList().get(0).getHeadPic(), rd_touxiang7);
								name_count7.setText(gethero.getHeroList().get(0).getAgent() + "("
										+ gethero.getHeroList().get(0).getCusAmount() + "万元)");
								playimage(gethero.getHeroList().get(1).getHeadPic(), rd_touxiang8);
								name_count8.setText(gethero.getHeroList().get(1).getAgent() + "("
										+ gethero.getHeroList().get(1).getCusAmount() + "万元)");
								playimage(gethero.getHeroList().get(2).getHeadPic(), rd_touxiang9);
								name_count9.setText(gethero.getHeroList().get(2).getAgent() + "("
										+ gethero.getHeroList().get(2).getCusAmount() + "万元)");
							}
							if (null == gethero.getHeroList()) {
								name_count7.setText("???");
								name_count8.setText("???");
								name_count9.setText("???");
								playimage("111", rd_touxiang7);
								playimage("111", rd_touxiang8);
								playimage("111", rd_touxiang9);
							}
						}
					}
					gethero = new GetHeroList();
					if (open == 1) {
						getHeroList(2, timeType, 2, cusSort);
					} else if (open == 2) {
						getHeroList(3, timeType, 0, cusSort);
					}
				} else {
					EmmApplication.T(gethero.getErrorMsg().toString());
					Log.v("获取失败", "errorCode:" + gethero.getErrorCode().toString() + "errorMsg:"
							+ gethero.getErrorMsg().toString());
				}
			}
		});
	}

	private void playimage(String url, RoundImageView view) {
		EmmApplication.imageLoader.displayImage(url, view, EmmApplication.options);
	}
}